package com.my.chapter11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;

public class practice12 {
    public static void main(String[] args) {
        List<Integer> list1 = new ArrayList<Integer>(Arrays.asList(1,2,3));
        List<Integer> list2 = new ArrayList<Integer>(Arrays.asList(4,5,6));
        ListIterator<Integer> it1 = list1.listIterator();
        ListIterator<Integer> it2 = list2.listIterator();
        System.out.print("list1：[");
        while(it1.hasNext()){
            System.out.print(it1.next() + " ");
        }
        System.out.println("]");

        System.out.print("list2：[");
        while(it2.hasNext()){
            System.out.print(it2.next() + " ");
        }
        System.out.println("]");

        while (it1.hasPrevious()){
            list2.add(it1.previous());
        }
        System.out.println(list2);
    }
}
